﻿import clr

clr.AddReference('System.Windows.Forms')
clr.AddReference('SunrayEngine')

from SunrayEngine import PopBox

from System.Windows.Forms import MessageBox

def addscript(name, func):
    scriptmanager.AddScript(name, func)

def setscripts(scriptm):
    global scriptmanager
    scriptmanager = scriptm

    addscript("print", script_print)
    addscript("printlist", script_printlist)
    addscript("source", script_source)

def script_print(s):
    print str(eval(s))

def script_printlist(s):
    for x in eval(s):
        print x

def script_source(s):
    try:
        PopBox.Show("source of %s:" % s, game.Py.GetSource(s))
    except IOError:
        print "Unable to find source."
